#include <iostream>
#include <cstring>
#include <cerrno>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

using namespace std;

int main() {
    int wfd = open("fifo", O_WRONLY);
    if (wfd < 0) {
        cerr << "errno: " << errno << ", errstring:" << strerror(errno) << endl;
        return -1;
    }
    cout << "open fifo sucess……" << endl;

    string message;
    while (true) {
        cout << "Plesase Enter:";
        getline(cin, message);
        ssize_t n = write(wfd, message.c_str(), message.size());
        if (n < 0) {
            cerr << "errno: " << errno << ", errstring:" << strerror(errno) << endl;
            break;
        }
        
    }
    cout << "clint close……" << endl;
    close(wfd);
    return 0;
}